package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HaDoctors;
import com.ruoyi.system.service.IHaDoctorsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医生列表Controller
 * 
 * @author 鲍小伟
 * @date 2025-11-11
 */
@RestController
@RequestMapping("/system/doctors")
public class HaDoctorsController extends BaseController
{
    @Autowired
    private IHaDoctorsService haDoctorsService;

    /**
     * 查询医生列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:doctors:list')")
    @GetMapping("/list")
    public TableDataInfo list(HaDoctors haDoctors)
    {
        startPage();
        List<HaDoctors> list = haDoctorsService.selectHaDoctorsList(haDoctors);
        return getDataTable(list);
    }

    /**
     * 导出医生列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:doctors:export')")
    @Log(title = "医生列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HaDoctors haDoctors)
    {
        List<HaDoctors> list = haDoctorsService.selectHaDoctorsList(haDoctors);
        ExcelUtil<HaDoctors> util = new ExcelUtil<HaDoctors>(HaDoctors.class);
        util.exportExcel(response, list, "医生列表数据");
    }

    /**
     * 获取医生列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:doctors:query')")
    @GetMapping(value = "/{did}")
    public AjaxResult getInfo(@PathVariable("did") Long did)
    {
        return success(haDoctorsService.selectHaDoctorsByDid(did));
    }

    /**
     * 新增医生列表
     */
    @PreAuthorize("@ss.hasPermi('system:doctors:add')")
    @Log(title = "医生列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HaDoctors haDoctors)
    {
        return toAjax(haDoctorsService.insertHaDoctors(haDoctors));
    }

    /**
     * 修改医生列表
     */
    @PreAuthorize("@ss.hasPermi('system:doctors:edit')")
    @Log(title = "医生列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HaDoctors haDoctors)
    {
        return toAjax(haDoctorsService.updateHaDoctors(haDoctors));
    }

    /**
     * 删除医生列表
     */
    @PreAuthorize("@ss.hasPermi('system:doctors:remove')")
    @Log(title = "医生列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dids}")
    public AjaxResult remove(@PathVariable Long[] dids)
    {
        return toAjax(haDoctorsService.deleteHaDoctorsByDids(dids));
    }
}
